
import unittest



# from openerp.modules.registry import RegistryManager
from itsbroken.transaction import Transaction
from itsbroken.testing import DB_NAME, POOL, USER, CONTEXT, \
    install_module, drop_database


class TestItsBroken(unittest.TestCase):
    """
    Test the itsbroken library by connecting to an instance of
    OpenERP.

    By defualt OpenERP has the partner module and other core modules
    installed, so most of the test uses those modules.
    """
    def setUp(self):
        install_module('product')

    def test_0010_create(self):
        """
        Test by creating a new product
        """
        with Transaction().start(DB_NAME, USER, CONTEXT) as txn:
            product_obj = POOL.get('product.product')

            values = {
                'name': 'Sharoon Thomas'
            }
            id = product_obj.create(
                txn.cursor, txn.user, values, txn.context
            )
            product = product_obj.browse(txn.cursor, txn.user, id)
            self.assertEqual(product.name, values['name'])


if __name__ == '__main__':
    unittest.main()